1. Technology Field
The present invention relates to a flash memory management method and a flash memory controller and a flash memory storage system using the same.
2. Description of Related Art
Along with the widespread of digital cameras, cell phones, and MP3 in recently years, the consumers' demand to storage media has increased drastically. Flash memory is one of the most adaptable memories for such battery-powered portable products due to its characteristics such as data non-volatility, low power consumption, small volume, and non-mechanical structure. A solid state drive (SSD) is a storage device which uses a NAND flash memory as its storage medium. Flash memory has been broadly used for storing important personal data thanks to its small volume and large capacity. Thereby, the flash memory industry has become a very important part of the electronic industry in recent years.
The flash memory chip in a flash memory storage apparatus has a plurality of physical blocks, and each of the physical blocks has a plurality of physical pages, wherein each physical block is an erasing unit of the flash memory chip while each physical page is a writing unit of the flash memory chip. Because a flash memory chip can only be programmed (i.e., written) in a single direction (i.e., the value of a memory cell thereof can only be programmed from 1 to 0), data cannot be directly written into a physical page that has been programmed before (i.e., a page contains data). Instead, the page has to be erased first before it can be programmed. In particular, since a flash memory chip is erased in unit of physical blocks, when a physical page containing old data is to be erased, the entire physical block corresponding to the physical page has to be erased. Since a flash memory is written in unit of physical pages while erased in unit of physical blocks, physical blocks in the flash memory are logically grouped into a system area, a data area, a spare area, and a replacement area by a flash memory controller of the flash memory storage apparatus. The physical blocks in the system area are configured to store important relevant information of the flash memory storage system. On the other hand, the physical blocks in the replacement area are configured to replace the damaged physical blocks in the data area or the spare area. Therefore, under normal access mode, the host system cannot access the physical blocks in the system area and the replacement area. The physical blocks in the data area are used for storing valid data written by write commands, and the physical blocks in the spare area are used for substituting the physical blocks in the data area when the write commands are executed. To be specific, when a flash memory storage apparatus receives a write command and new data corresponding to the write command from a host system and accordingly is about to update a physical block in the data area, the flash memory storage apparatus gets a physical block from the spare area and writes the old valid data stored in the physical block to be updated and the new data into the physical block gotten from the spare area. Then, the flash memory storage apparatus logically associates the physical block containing the new data to the data area and erases the physical block to be updated and logically associates it to the spare area. The flash memory storage apparatus provides logical addresses to the host system in order to allow the host system to smoothly access the physical blocks alternatively used for storing data. More specifically, the flash memory storage apparatus may maintain a logical address-physical address mapping table in which mapping relationships between the logical addresses and the physical blocks in the data area is recorded to reflect the alternation of the physical blocks. Thus, the host system simply writes data into a logical address while the flash memory storage apparatus reads data from or writes data into the physical page of the mapped physical block according to the logical address-physical address mapping table.
Because the flash memory storage apparatus alternatively uses the physical blocks for storing data written by the host system, the flash memory storage apparatus must organize valid data in the physical block of the data area when the number of the physical blocks in the spare area is not enough for storing data. For example, the flash memory controller of the flash memory storage apparatus moves valid data that belongs to the same logical block to the same physical block, thereby releasing the physical block stored invalid data. However, the time for organizing valid data causes the increase of the time for executing a host write-in command. Therefore, when the flash memory storage apparatus frequently organizes valid data stored in the physical blocks of the data area, the performance of the flash memory storage apparatus would be dropped drastically.
Nothing herein should be construed as an admission of knowledge in the prior art of any portion of the present invention. Furthermore, citation or identification of any document in this application is not an admission that such document is available as prior art to the present invention, or that any reference forms a part of the common general knowledge in the art.